﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Data;
using System.Data.SqlClient;
using Newtonsoft.Json;
using CMD_WEB.DAL;

namespace CMD.BAL.SOL
{
    [DataContractAttribute]
   public class DetallesWeb
   {
        [DataMemberAttribute(EmitDefaultValue = false)]
        public string parametrosDetalle;        
        public static int InsertDetalle(string parametrosDetalle)
        {
            DataSet result = new DataSet();
            SqlCommand sp = new SqlCommand("SP_CMD_WF_SETDETALLE");
            sp.CommandType = CommandType.StoredProcedure;
            Dictionary<string, string> values = JsonConvert.DeserializeObject<Dictionary<string, string>>(parametrosDetalle);
            //UpsertSolicitudWeb solweb= null;
            int mensaje = 0;
            try
            {
                foreach (KeyValuePair<string, string> d in values)
                {
                    sp.Parameters.AddWithValue(d.Key, d.Value);
                }
                result = SrvDB.ExecuteCommand(sp);
                if (result.Tables.Count == 0)
                {
                    mensaje = 1;
                }
                if (result.Tables.Count == 1)
                {
                    mensaje = 0;
                }
                    
            }

            catch (Exception ex)
            {
                throw ex;
            }
            //return  solweb.unidSolicitud.ToString();
            return mensaje;
        }

        public DetallesWeb()
        {
            parametrosDetalle = "";
        }

   }
}
